﻿using System.Collections.Generic;
using NUnit.Framework;
using StringExt;

namespace DictionaryExt.Test {

    [TestFixture]
    public class ToDictionaryExceptionWith1Sep {

        [Test]
        public void MissingSep() {
            Assert.Throws<StringExt.PatternException>(MissingSepException);
        }
        static void MissingSepException() {
            const string s = "a1";
            IDictionary<string, string> result = s.ToDictionary(StringExt.StringExt.RemoveSurroundingBlanks.No);
            Assert.AreEqual(1, result.Count);
        }

        [Test]
        public void Ending1Sep() {
            Assert.Throws<StringExt.PatternException>(Ending1SepException);
        }
        static void Ending1SepException() {
            const string s = "a=";
            IDictionary<string, string> result = s.ToDictionary(StringExt.StringExt.RemoveSurroundingBlanks.No);
            Assert.AreEqual(1, result.Count);
        }

        [Test]
        public void Ending2Sep() {
            Assert.Throws<StringExt.PatternException>(Ending2SepException);
        }
        static void Ending2SepException() {
            const string s = "a==";
            IDictionary<string, string> result = s.ToDictionary(StringExt.StringExt.RemoveSurroundingBlanks.No);
            Assert.AreEqual(1, result.Count);
        }

        [Test]
        public void Leading2Sep() {
            Assert.Throws<StringExt.PatternException>(Leading2SepException);
        }
        static void Leading2SepException() {
            const string s = "==a";
            IDictionary<string, string> result = s.ToDictionary(StringExt.StringExt.RemoveSurroundingBlanks.No);
            Assert.AreEqual(1, result.Count);
        }
    }

}
